<% layout('/layouts/default.html', {title: '其它入库单管理', libs: ['validate','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(otherInboundHeader.isNewRecord ? '新增其它入库单' : '编辑其它入库单')}
			</div>
			<div class="box-tools pull-right hide">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${otherInboundHeader}" action="${ctx}/otherinbound/header/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="autoId"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('组织ID')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="orgId" maxlength="17" class="form-control required digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('组织编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="orgCode" maxlength="10" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('组织名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="orgName" maxlength="30" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('入库单号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="billNo" maxlength="30" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('入库日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="billDate" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('单据状态')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="billStatus" maxlength="1" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('ERP单据ID')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="erpBillId" maxlength="30" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('ERP单据号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="erpBillNo" maxlength="30" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('单据来源类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="sourceBillType" maxlength="1" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('来源单据ID')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="sourceBillId" maxlength="64" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('来源单号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="sourceBillNo" maxlength="64" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('仓库ID')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="warehouseId" maxlength="17" class="form-control digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('部门ID')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="deptId" maxlength="17" class="form-control digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('收发类别编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="rdCode" maxlength="30" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('业务类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="businessType" maxlength="30" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('创建人名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="createName" maxlength="50" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('更新人名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="updateName" maxlength="50" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('审核人')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="auditBy" maxlength="30" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('审核人名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="auditName" maxlength="50" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('审核时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="auditDate" readonly="true" maxlength="20" class="form-control laydate"
									dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('其它入库单行表')}</div>
				<div class="form-unit-wrap table-form">
					<table id="linesDataGrid"></table>
					<% if (hasPermi('otherinbound:header:edit')){ %>
						<a href="#" id="linesDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>
					<% } %>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('otherinbound:header:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//# // 初始化其它入库单行表DataGrid对象
$('#linesDataGrid').dataGrid({

	data: "#{toJson(otherInboundHeader.linesList)}",
	datatype: 'local', // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	//# // 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'autoId', editable:true, hidden:true},
		{header:'${text("头表ID")}', name:'headerId.autoId', editable:true, hidden:true},
		{header:'${text("单据来源类型")}', name:'sourceBillType', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'1', 'class':'form-control'}},
		{header:'${text("来源单据ID")}', name:'sourceBillId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
		{header:'${text("来源单号")}', name:'sourceBillNo', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
		{header:'${text("来源单据DID")}', name:'sourceBillLineId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
		{header:'${text("行号")}', name:'sourceBillRowNo', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'8', 'class':'form-control digits'}},
		{header:'${text("仓库ID")}', name:'warehouseId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'17', 'class':'form-control digits'}},
		{header:'${text("仓区ID")}', name:'areaId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'17', 'class':'form-control digits'}},
		{header:'${text("货架ID")}', name:'shelvesId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'17', 'class':'form-control digits'}},
		{header:'${text("仓位ID")}', name:'positionId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'17', 'class':'form-control digits'}},
		{header:'${text("存货ID")}', name:'invId', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'17', 'class':'form-control digits'}},
		{header:'${text("数量")}', name:'qty', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'22', 'class':'form-control number'}},
		{header:'${text("备注")}', name:'remarks', width:150, editable:true, edittype:'textarea', editoptions:{'maxlength':'255', 'class':'form-control', 'rows':'1'}},
		{header:'${text("操作")}', name:'actions', width:80, align:'center', formatter: function(val, obj, row, act){
			var actions = [];
			if (val == 'new'){
				actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#linesDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			}else{
				actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#linesDataGrid\').dataGrid(\'setRowData\',\''+obj.rowId+'\',null,{display:\'none\'});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			}
			return actions.join('');
		}, editoptions: {defaultValue: 'new'}}
	],
	
	//# // 编辑表格参数
	editGrid: true,				// 是否是编辑表格
	editGridInitRowNum: 1,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#linesDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowBtnToHeader: true,	// 子表增行按钮是否显示到表头上
	editGridAddRowInitData: {autoId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

	//# // 编辑表格的提交数据参数
	editGridInputFormListName: 'linesList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,autoId,headerId.autoId,sourceBillType,sourceBillId,sourceBillNo,sourceBillLineId,sourceBillRowNo,warehouseId,areaId,shelvesId,positionId,invId,qty,remarks,', // 提交数据列表的属性字段
	
	//# // 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
<script>
$('#inputForm').validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>